package edu.nanyang.struts;

import java.util.List;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionSupport;

import edu.nanyang.domain.City;
import edu.nanyang.hibernate.service.ICityService;
import edu.nanyang.hibernate.service.IProvinceService;
import edu.nanyang.util.ProvinceCityBean;

public class ChangeCityAction extends ActionSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private List<ProvinceCityBean> provinceCitys;
	private IProvinceService provinceService;
	private ICityService cityService;
	private int cityId;
	private String result;
	public String changeCurrentCity(){
		City city=new City();
		City c=this.cityService.acquireCityByCityId(cityId);
		if(c!=null){
			city.setId(c.getId());
			city.setName(c.getName());
			ServletActionContext.getRequest().getSession().setAttribute("city", city);
		}else{
			
		}
		System.out.println("cityId========"+cityId);
		return SUCCESS;
	}
	public String acquireAllProvinceCity(){
		this.provinceCitys=this.provinceService.acquireAllProvinceCity();
		return SUCCESS;
	}

	public List<ProvinceCityBean> getProvinceCitys() {
		return provinceCitys;
	}

	public void setProvinceCitys(List<ProvinceCityBean> provinceCitys) {
		this.provinceCitys = provinceCitys;
	}

	public void setProvinceService(IProvinceService provinceService) {
		this.provinceService = provinceService;
	}
	public int getCityId() {
		return cityId;
	}
	public void setCityId(int cityId) {
		this.cityId = cityId;
	}
	public void setCityService(ICityService cityService) {
		this.cityService = cityService;
	}
	public String getResult() {
		return result;
	}
	public void setResult(String result) {
		this.result = result;
	}
	
}
